<!-- src/components/Calendar/UserCard.vue -->
<template>
  <teleport to="body">
    <transition name="user-menu-fade">
      <div 
        v-if="showUserCard" 
        class="user-menu-mask" 
        @click="$emit('close-user-card')"
      >
        <div class="user-card" @click.stop>
          <!-- 用户信息区域 -->
          <div class="user-info">
            <div class="user-avatar-large">
              <img src="@/assets/img1.jpg" alt="用户头像" />
            </div>
            <div class="user-name">Hypno-Shroom</div>
          </div>
          
          <!-- 按钮区域 -->
          <div class="user-actions">
            <button class="action-btn manage-btn" @click="$emit('manage-account')">
              管理账号
            </button>
            <button class="action-btn logout-btn" @click="$emit('logout')">
              退出账号
            </button>
          </div>
        </div>
      </div>
    </transition>
  </teleport>
</template>

<script lang="ts" setup>
interface Props {
  showUserCard: boolean
}

defineProps<Props>()

const emit = defineEmits([
  'close-user-card',
  'manage-account',
  'logout'
])
</script>

<style scoped>
.user-menu-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 70px;
  padding-right: 20px;
  z-index: 1000;
}

.user-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 24px;
  width: 280px;
  backdrop-filter: blur(10px);
}

.user-info {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.user-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 12px;
  border: 3px solid #f0f0f0;
}

.user-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.user-actions {
  display: grid;
  flex-direction: column;
  gap: 12px;
}

.action-btn {
  width: 100%;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.manage-btn {
  background: #1976d2;
  color: white;
}

.manage-btn:hover {
  background: #1565c0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.logout-btn {
  background: #f5f5f5;
  color: #666;
}

.logout-btn:hover {
  background: #eeeeee;
  color: #333;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-menu-fade-enter-active,
.user-menu-fade-leave-active {
  transition: all 0.3s ease;
}

.user-menu-fade-enter-from {
  opacity: 0;
}

.user-menu-fade-leave-to {
  opacity: 0;
}

.user-menu-fade-enter-from .user-card,
.user-menu-fade-leave-to .user-card {
  transform: translateY(-10px) scale(0.95);
}

.user-menu-fade-enter-active .user-card,
.user-menu-fade-leave-active .user-card {
  transition: all 0.3s ease;
}

.user-menu-fade-enter-to .user-card,
.user-menu-fade-leave-from .user-card {
  transform: translateY(0) scale(1);
}

@media (max-width: 768px) {
  .user-menu-mask {
    padding-top: 60px;
    padding-right: 10px;
    padding-left: 10px;
    align-items: flex-start;
    justify-content: center;
  }
  
  .user-card {
    width: 90%;
    max-width: 300px;
  }
}
</style>